﻿Shader "CCGame/CCRole"
{
    Properties
    {
        [Header(Base Color)]
        [HDR][MainColor]_BaseColor("BaseColor", Color) = (1,1,1,1)
        [MainTexture]_BaseMap ("BaseMap", 2D) = "white" {}
        
        [Header(Lighting)]
        _IndirectLightConstColor("IndirectLightConstColor", Color) = (0.5,0.5,0.5,1)
        _IndirectLightMultiplier("IndirectLightMultiplier", Range(0,1)) = 1
        
        _DirectLightMultiplier("DirectLightMultiplier",Range(0,1)) = 0
        _CelShadeMidPoint("CelSHadeMidPoint",Range(-1,1)) = -0.5
        _CelShadeSoftness("CselShadeSoftness",Range(0,1)) = 0.05
        _MainLightIgnoreCelShade("MainLightIgnoreCelShade", Range(0,1)) =  0
        _AdditionalLightIgnoreCelShade("_AdditionalLightIgnoreCelShade", Range(0,1)) = 0.9
        
        
        [Header(Shadow Mapping)]
        _ReceiveShadowMappingAmount("ReceiveShadowMappingAmount", Range(0,1)) = 0.5
        
        [Header(Emission)]
        [Toggle] _UseEmission("UseEmission", Float) = 0
        [HDR] _EmissionColor("EmissionColor", Color) = (1,1,1,1)
        _EmissionMulByBaseColor("EmissionMulByBaseColor",Range(0,1)) = 0
        [NoScaleOffset]_EmissionMap("EmissionMap", 2D) = "white" {}
        _EmissionMapChannelMask("EmissionMapChannelMask", Color) = (1,1,1,1)
        
        [Header(Outline)]
        _OutlineWidth("OutlineWidth", Range(0,4)) =1
        _OutlineColor("OutlineColor", Color) = (0.5,0.5,0.5,1)
        _OutlineZOffset("OutlineZOffset", Range(0,1)) = 0.75
        [NoScaleOffset]_OutlineZOffsetMaskTex("OutlineZOffsetMaskTex", 2D) = "black" {}
        _OutlineZOffsetMaskRemapStart("OutlineZOffsetMaskRemapStart",Range(0,1)) = 0
        _OutlineZOffsetMaskRemapEnd("OutlineZOffsetMaskRemapEnd",Range(0,1)) = 1
        
        
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100

        Pass
        {
            Name "Forward"
        
            Tags { "LightMode" = "UniversalForward"}
            
            Cull Back
            ZTest LEqual
            ZWrite On
            Blend One Zero
            
            HLSLPROGRAM
            
            
            #include "CCRole.hlsl"
            
            
            #pragma multi_compile _ _MAIN_LIGHT_SHADOWS
            
            
            // ---------------------------------------------------------------------------------------------
            // Unity defined keywords
            #pragma multi_compile_fog
            // ---------------------------------------------------------------------------------------------

            
            #pragma vertex VertexRole
            
            #pragma fragment FragRole
            
            
            
            
            ENDHLSL
        }
        Pass{
            Name "Outline"
            Tags{
                
            }
            Cull Front
            
            HLSLPROGRAM
            
            
            // ---------------------------------------------------------------------------------------------
            // Unity defined keywords
            #pragma multi_compile_fog
            // ---------------------------------------------------------------------------------------------
            #define ToonShaderIsOutline
            
            #include "CCRole.hlsl"
            
            
            
            #pragma vertex VertexRole
            
            #pragma fragment FragRole
            
            ENDHLSL
        }
    }
}
